<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="824.42">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
    p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
    p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
    p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
    p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
    p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
    p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
    p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #bf0000}
    p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #0000bf}
    span.s1 {text-decoration: underline}
    span.s2 {color: #0000bf}
    span.s3 {color: #007300}
    span.s4 {color: #000000}
    span.Apple-tab-span {white-space:pre}
  </style>
</head>
<body>
<p class="p1"><b>Balance -<span class="Apple-converted-space">    <span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></span>balances two signals with each other</b></p>
<p class="p2"><b></b><br></p>
<p class="p3"><b>Balance(in, test, numperiods, mul, add)</b></p>
<p class="p4"><b></b><br></p>
<p class="p5"><span class="s1"><b>Usage</b></span></p>
<p class="p4"><b></b><br></p>
<p class="p3"><b>in - the signal you want to balance</b></p>
<p class="p3"><b>test - the signal that should be used to balance in. If test is a k-rate sig, it will represent a target RMS.</b></p>
<p class="p4"><b></b><br></p>
<p class="p3"><b>Balance will try to match the RMS levels of in to the RMS of test</b></p>
<p class="p4"><b></b><br></p>
<p class="p4"><b></b><br></p>
<p class="p6">s = <span class="s2">Server</span>.internal.boot;</p>
<p class="p6">s.scope(2);</p>
<p class="p7"><br></p>
<p class="p6"><span class="s2">SynthDef</span>(<span class="s3">\noise</span>, {<span class="s2">arg</span> noiseout = 1;</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s2">var</span> noise, filt;</p>
<p class="p6"><span class="Apple-tab-span">	</span>noise = <span class="s2">WhiteNoise</span>.ar(<span class="s2">MouseX</span>.kr(0, 1));</p>
<p class="p6"><span class="Apple-tab-span">	</span>filt = <span class="s2">BPF</span>.ar(noise, <span class="s2">LFNoise2</span>.kr(0.2, 440, 880), 0.001);</p>
<p class="p8"><span class="s4"><span class="Apple-tab-span">	</span></span>// comment out to compare without balance</p>
<p class="p6"><span class="Apple-tab-span">	</span>filt = <span class="s2">Balance</span>.ar(filt, <span class="s2">Amplitude</span>.kr(noise, 0.01, 0.2).max(0.01));</p>
<p class="p8">//<span class="Apple-tab-span">	</span>filt = filt * 1000;</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s2">Out</span>.ar(0, [filt, noise * noiseout]);</p>
<p class="p6"><span class="Apple-tab-span">	</span>}).load(s);</p>
<p class="p7"><span class="Apple-tab-span">	</span></p>
<p class="p6">s.sendMsg(<span class="s3">\s_new</span>, <span class="s3">\noise</span>, a = s.nextNodeID, 0, 1);</p>
<p class="p6">s.sendMsg(<span class="s3">\n_set</span>, a, <span class="s3">\noiseout</span>, 0);</p>
<p class="p6">s.sendMsg(<span class="s3">\n_free</span>, a);</p>
<p class="p7"><br></p>
<p class="p9">SynthDef<span class="s4">(</span><span class="s3">\test</span><span class="s4">, {</span></p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s2">var</span> src, sig;</p>
<p class="p6"><span class="Apple-tab-span">	</span>src = <span class="s2">SinOsc</span>.ar(440, 0, <span class="s2">MouseX</span>.kr(0, 1));</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s2">SinOsc</span>.ar(440, 0, 0.1);</p>
<p class="p8"><span class="s4"><span class="Apple-tab-span">	</span></span>// comment out to compare without balance</p>
<p class="p6"><span class="Apple-tab-span">	</span>sig = <span class="s2">Balance</span>.ar(sig, src);</p>
<p class="p6"><span class="Apple-tab-span">	</span><span class="s2">Out</span>.ar(0, [src, sig]);</p>
<p class="p6"><span class="Apple-tab-span">	</span>}).load(s);</p>
<p class="p7"><span class="Apple-tab-span">	</span></p>
<p class="p6">s.sendMsg(<span class="s3">\s_new</span>, <span class="s3">\test</span>, a = s.nextNodeID, 0, 1);</p>
<p class="p7"><br></p>
<p class="p6">s.sendMsg(<span class="s3">\n_free</span>, a);</p>
</body>
</html>
